<?php

 require_once('bugs/core.php');

 if (get_magic_quotes_gpc()) {
  foreach ($_REQUEST as $k => $v) { $_REQUEST[$k] = stripslashes($v); }
 }

 // Log us in to the bug tracker
 auth_attempt_script_login('Error Reporter');

 if (isset($_REQUEST['feedback']) && isset($_REQUEST['version'])) {
  $name = isset($_REQUEST['name']) ? $_REQUEST['name'] : "Not given";
  $email = isset($_REQUEST['email']) ? $_REQUEST['email'] : "Not given";
  $feedback = $_REQUEST['feedback'];
  $serverInfo = isset($_REQUEST['serverInfo']) ? $_REQUEST['serverInfo'] : "Not given";
  $version = $_REQUEST['version'];
  $ip = $_SERVER['REMOTE_ADDR'];
  $date = date('r');

  $bugdata = new BugData();
  $bugdata->project_id = 1;
  $bugdata->reporter_id = 10;
  $bugdata->build = $version;
  $bugdata->view_state = VS_PRIVATE;
  $bugdata->summary = "Feedback from $name <$email>";
  $bugdata->description = $feedback;
  $bugdata->category = 'Feedback';

  $id = bug_create($bugdata);

  bugnote_add($id, "IP address: $ip", '0:00', true);

  if ($serverInfo != "Not given") {
   bugnote_add($id, "Server information:\n\n" . $serverInfo, '0:00', true);
  }

  echo "Thank you. Your feedback has been recorded for the DMDirc developers.";

 } else {
  die('Failure: Invalid parameters.');
 }
?>
